﻿using Crowler.Model.CoreComponents.DataAccess;
using NHibernate.Cfg;

namespace CoreComponents.DataAccess
{
    public class NHibernateConfigurationProvider : INHibernateConfigurationProvider
    {
        private Configuration _nhibernateConfiguration;
        public Configuration CreateNHibernateConfiguration()
        {
            if (_nhibernateConfiguration == null)
            {
                _nhibernateConfiguration = new Configuration();
                _nhibernateConfiguration.Configure();
                foreach (var assembly in SolutionAssemblies.GetAssemblies())
                {
                    _nhibernateConfiguration.AddAssembly(assembly);    
                }
            }
            return _nhibernateConfiguration;
        }
    }
}
